<title>分类管理</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>应用</cite></a>
        <a><cite>分类管理</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <button class="layui-btn layuiadmin-btn-tags" data-type="add">添加</button>
        </div>
        <div class="layui-card-body">
            <table id="LAY-app-content-tags" lay-filter="LAY-app-content-tags"></table>
            <script id="layuiadmin-app-cont-tagsbar" type="text/html">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
                        class="layui-icon layui-icon-edit"></i>编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
                        class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>

<script>
    layui.use('contlist', layui.factory('contlist')).use(['admin', 'contlist', 'table'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , table = layui.table
            , form = layui.form;

        var active = {
            add: function () {
                admin.popup({
                    title: '添加分类'
                    , area: ['450px', '200px']
                    , id: 'LAY-popup-content-tags'
                    , success: function (layero, index) {
                        view(this.id).render('app/content/tagsform').done(function () {
                            form.render(null, 'layuiadmin-form-tags');

                            //监听提交
                            form.on('submit(layuiadmin-app-tags-submit)', function (data) {
                                var field = data.field; //获取提交的字段

                                //提交 Ajax 成功后，关闭当前弹层并重载表格
                                //$.ajax({});
                                layui.table.reload('LAY-app-content-tags'); //重载表格
                                layer.close(index); //执行关闭
                            });
                        });
                    }
                });
            }
        };
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>